package com.songlanyun.modules.freebaggive.controller;

import com.songlanyun.common.utils.R;
import com.songlanyun.modules.account.controller.common.AbstractApiController;
import com.songlanyun.modules.disabilityauth.entity.DisabilityAuthEntity;
import com.songlanyun.modules.freebaggive.service.FreeBagGiveService;
import com.songlanyun.modules.schedule.FreeBagGiveScheduleServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 福利发放和使用的流水
 *
 * @author lubo
 * @email sunlightcs@gmail.com
 * @date 2022-08-04 17:08:04
 */
@RestController
@RequestMapping("api/freebaggive")
public class ApiFreeBagGiveController extends AbstractApiController {
    @Autowired
    private FreeBagGiveService freeBagGiveService;

    @Autowired
    private FreeBagGiveScheduleServiceImpl freeBagGiveScheduleService;


    /**
     * 免费领取的次数
     */
    @RequestMapping("/limit")
    //@RequiresPermissions("disabilityauth:disabilityauth:info")
    public R info() {
        Integer freeLimit = freeBagGiveService.getFreeLimit(getUserId(true));
        return R.ok().put("data", freeLimit);
    }

    /**
     * 手动触发每月领取
     */
//    @PostMapping("/manualTrigger")
    public R manualTrigger() {
        freeBagGiveScheduleService.freeBagGiveTask();
        return R.ok();
    }

}
